package com.zhongkai.controller;

import com.zhongkai.app.service.BigDateService;
import com.zhongkai.model.utils.ZhongkaiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * 大数据监控
 * */
@Controller
public class BigDateServiceController {

    @Autowired
    private BigDateService bigDateService;



    /**
     * 状态监控
     * @param page 当前页数
     * @param rows 每页数据条数
     */
    @RequestMapping(value = "/big_date/unit_list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult getUnitBigDate(@RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "0")Integer rows) {

        ZhongkaiResult province = null;
        try {
            province = bigDateService.getUnitBigDate(page,rows);
        } catch (IOException e) {
            e.printStackTrace();

            return ZhongkaiResult.build(500,"数据转换异常");
        }

        return province;
    }



    /**
     *  获取大数据页面基本信息
     */
    @RequestMapping(value = "/big_date/basic", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult getUnitBasic() {

        ZhongkaiResult province = null;
        try {
            province = bigDateService.getUnitBasic();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return province;
    }




    /**
     *  获取大数据页面分析信息
     */
    @RequestMapping(value = "/big_date/analyze", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult getUnitAnalyze() {

        ZhongkaiResult province = null;
        try {
            province = bigDateService.getUnitAnalyze();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return province;
    }


    /**
     *  获取大数据设备分部信息
     */
    @RequestMapping(value = "/big_date/unit_dis", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult getUnitDis() {

        ZhongkaiResult province = null;
        try {

            province = bigDateService.getUnitDis();

        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return province;
    }
}
